home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 06 - 1990 / 06.11 Nov 90 / Transition Source / TransitionDemo.c < prev   
Encoding:
C/C++ Source or Header  |  1990-08-02  |  3.1 KB  |  127 lines  |  [TEXT/KAHL]

  1. /************************************/
  2. /* Application:  TransitionDemo
  3. Function:  Demonstrates different visual effects. */
  4. /************************************/ 
  5. /* #include file */
  6. #include "General.h"
  7. #include "Demo.h"
  8.  
  9. /* External variables and functions */
  10. extern void InitMyMenus(void);
  11. extern void HandleMenu(char *doneFlag, short theMenu, short theItem);
  12. extern void UpdateMenu();
  13.  
  14. /* globals variables and function prototypes */
  15. void main(void);
  16.  
  17. /************************************/
  18. /* Routines:
  19.     • void main()
  20.     */
  21. /************************************/
  22.  
  23. /************************************/
  24. /* void main()
  25.     main entry into Transition App */
  26. /************************************/
  27. void main()
  28. {
  29. char doneFlag;
  30. char ch;
  31. short code;
  32. short theMenu,theItem;
  33. long mResult;
  34. WindowPtr whichWindow;
  35. EventRecord myEvent;
  36. Rect tempRect;
  37. GrafPtr SavePort;
  38.  
  39. /* init Mac stuff */
  40. InitGraf(&thePort);
  41. InitFonts();
  42. FlushEvents(everyEvent,0);
  43. InitWindows();
  44. InitMenus();
  45. TEInit();
  46. InitDialogs(NIL);
  47. InitCursor();
  48.  
  49. /* init app stuff */
  50. doneFlag = FALSE;
  51. InitMyMenus();
  52. Init_Demo();
  53.  
  54. /* start transition */
  55. Open_Demo();
  56.  
  57. do { /* Main Event Loop */
  58.     SystemTask();
  59.  
  60.     if (GetNextEvent(everyEvent, &myEvent)) { /* got event */
  61.         code = FindWindow(myEvent.where, &whichWindow);    
  62.  
  63.         switch (myEvent.what) { /* event switch */
  64.             case mouseDown: /* mouse event */
  65.                 if (code == inMenuBar) { /* menu bar */
  66.                     UpdateMenu();
  67.                     mResult = MenuSelect(myEvent.where);
  68.                     theMenu = HiWord(mResult);
  69.                     theItem = LoWord(mResult);
  70.                     HandleMenu(&doneFlag,theMenu,theItem);
  71.                     } /* menu bar */
  72.  
  73.                  if ((code == inDrag)&&(whichWindow != NIL)) { /* drag bar */
  74.                      tempRect = screenBits.bounds;
  75.                      SetRect(&tempRect, tempRect.left + 10, tempRect.top + 25,
  76.                          tempRect.right - 10, tempRect.bottom - 10);
  77.                      DragWindow(whichWindow, myEvent.where, &tempRect);
  78.                     } /* drag bar */
  79.  
  80.                 if (code == inContent) { /* In a window */
  81.                     if (whichWindow != FrontWindow())
  82.                         SelectWindow(whichWindow);
  83.                     else {
  84.                         SetPort(whichWindow);
  85.                         Do_Demo (&myEvent);
  86.                         }
  87.                     } /* In a window */
  88.  
  89.                 if (code == inSysWindow) /* In a DA window */
  90.                     SystemClick(&myEvent, whichWindow);
  91.                 break; /* mouse event */
  92.  
  93.             case keyDown: /* key event */
  94.             case autoKey: 
  95.                 ch = myEvent.message &  charCodeMask;
  96.                 if (myEvent.modifiers & cmdKey) { /* command key event */
  97.                     mResult = MenuKey(ch);
  98.                     theMenu = HiWord(mResult);
  99.                     theItem = LoWord(mResult);
  100.                     if (theMenu != 0) 
  101.                         HandleMenu(&doneFlag, theMenu, theItem); 
  102.                     }
  103.                 break; /* key event */
  104.  
  105.             case updateEvt: /* update event */
  106.                 whichWindow = (WindowPtr)myEvent.message;
  107.                 GetPort(&SavePort);
  108.                 BeginUpdate(whichWindow);
  109.                 SetPort(whichWindow);
  110.                     UpDate_Demo(whichWindow);
  111.                 EndUpdate(whichWindow);
  112.                 SetPort(SavePort);
  113.                 break; /* update event */
  114.  
  115.             case activateEvt: /* activate event */
  116.                 if ((whichWindow != NIL) && (myEvent.modifiers & activeFlag))
  117.                     SelectWindow(whichWindow);
  118.                 break; /* activate event */
  119.  
  120.             default:
  121.                 break;
  122.             } /* event switch */
  123.         } /* got event */
  124.     } while (doneFlag ==  FALSE); /* Main Event Loop */
  125. DisposeWindow(MyWindow);
  126. }
  127.